﻿<from class="layui-form layui-form-pane" action="" id="form-addcatalog">
    <input type="hidden" name="id">
    <div class="layui-form-item">
        <label class="layui-form-label">名称</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required" autocomplete="off"
                   placeholder="请输入名称" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item" style="text-align: center;">
        <button class="layui-btn" lay-submit="" lay-filter="favorite-catalog-edit">确认提交</button>
    </div>
</from>
<script type="text/javascript">

    layui.define(['layer', 'form'], function () {
        var form = layui.form;
        form.render();
        var id = workUtils.get("id");
        $.getJSON("../favorite/getcatalog/" + id, function (data) {
            $("[name='title']").val(data.title);
            $("[name='id']").val(data.id);
            form.render(); //这个很重要
        });

        form.on('submit(favorite-catalog-edit)', function (data) {
            var index = layer.load(1);
            setTimeout(function () {
                workUtils.ajaxPost("../favorite/addcatalog", data.field, function (result) {
                    layer.close(index);
                    workUtils.msg(result);
                    loadFavoriteCatalog();
                })
            }, 400);
            return false;
        });
    });
</script>